<%-- 
    Document   : UserSave
    Created on : 11-oct-2011, 0:30:48
    Author     : TOSHIBA
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="edu.upeu.examlp1.comm.Conexion" %>
<%
String go=request.getParameter("go");
if(go.equals("Create"))
        try {
            Conexion conn = new Conexion();
            
            String qry="insert into User(Name, Email, Cellular) values(?,?,?)";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ps.setString(1, request.getParameter("nombre") );
            ps.setString(2, request.getParameter("email") );
            ps.setInt(3, Integer.parseInt(request.getParameter("celular")));
            int r=ps.executeUpdate();
            out.println(r+" registros add in User table<br>");
            conn.close();
        } catch (Exception e) {
            out.print("Error: " +e.getMessage());
        }
if(go.equals("Edit"))
        try {
            Conexion conn = new Conexion();
            
            String qry="update User set "+
                    "Name=?, Email=?, Cellular=?"+
                    " where UserId=?";
            PreparedStatement ps=conn.getConnection().prepareStatement(qry);
            ps.setString(1, request.getParameter("nombre") );
            ps.setString(2, request.getParameter("email") );
            ps.setInt(3, Integer.parseInt(request.getParameter("celular")));
            ps.setString(4, request.getParameter("userId") );
            int r=ps.executeUpdate();
            out.println(r+" registros edit in User table<br>");
            conn.close();
        } catch (Exception e) {
            out.print("Error: " +e.getMessage());
        }    
%>
Espere..